<!DOCTYPE html>
<html lang="en">
<head>
	<meta charset="UTF-8">
	<meta name="viewport" content="width=device-width, initial-scale=1.0">
	<meta http-equiv="X-UA-Compatible" content="ie=edge">
	<link href="./../css/dialog-polyfill.css" rel="stylesheet" type="text/css" />
	<style type></style>
	<style>
		#chrome::backdrop{
			background-color: tan;
		}

		dialog + .backdrop { /* polyfill */
			background-color: green;
		}
		#polyfill::backdrop{
			background-color: green;
		}
	</style>
</head>
<body>
	<dialog id="chrome">
		<img src="./img/bg.jpg" width="100" height="100"/>
	</dialog>
	<button>open</button>

	<br />
	<br />

	<dialog id="polyfill">
		polyfill
			<img src="./img/bg.jpg" width="100" height="100"/>
	</dialog>
	<button>open-polyfill</button>
</body>
<script src="./../js/dialog-polyfill.js"></script>
<script>
	let dialog1 = document.querySelector("dialog");
	let button1 = document.querySelector("button");

	button1.onclick = ()=>{
		dialog1.showModal();
	}

	document.body.onclick = (e) => {
		console.log(e.currentTarget);
		console.log(e.target);

		if(e.target === dialog1)dialog1.close();
		if(e.target === dialog2)dialog2.close();
	}


	let dialog2 = document.querySelector("#polyfill");
	let button2 = document.querySelectorAll("button")[1];
	
	dialogPolyfill.registerDialog(dialog2);

	button2.onclick = ()=>{
		dialog2.showModal();
	}

</script>
</html>